﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Model;
using Kaidou.Persister;
using Kaidou.Util;
using Kaidou.Bll;
using System.Collections.Generic;
using System.Globalization;
using System.Text;


public partial class seal_seal_report_detail_kumi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }

        if (!loginModel.isKumiaiin())
        {
            Response.Redirect("../menu.jsp");
        }

        if (loginModel.isKumiaiin() && sessioncontrol.control())
        {
            Response.Redirect("../control.aspx");
        }

        try
        {
            if (!IsPostBack)
            {
                string report_no = Request.QueryString["report_no"].ToString();
                TRN_Report_D_Persister dao1 = new TRN_Report_D_Persister();
                TRN_Report_H_Persister dao2 = new TRN_Report_H_Persister();
                MST_TraderPersister dao3 = new MST_TraderPersister();
                MST_UnionPersister dao4 = new MST_UnionPersister();
                MST_Union_BranchPersister dao5 = new MST_Union_BranchPersister();
                TRN_ReportManager manager = new TRN_ReportManager();

                Report rpt = new Report();

                ArrayList reports = dao1.get(report_no);
                TrnReporth model = dao2.getDetail(report_no);
                TrnReportd[] model_D = new TrnReportd[5];
                int i = 0;
                /*
                for (i = 0; i < 5; i++)
                {
                    model_D[i] = new TrnReportd();
                }
                 * */
                for (i = 0; i < reports.Count; i++)
                {
                    model_D[((TrnReportd)reports[i]).Id.ReportRecNo - 1] = (TrnReportd)reports[i];

                }
                rpt.setReportH(model);
                rpt.setReportD(model_D);
                if (TrnReporth.STATUS_UNCHECK.Equals(model.ReportSts))
                {
                    Button4.Visible = true;
                    Button5.Visible = true;
                }
                else
                {
                    Button4.Visible = false;
                    Button5.Visible = false;
                }
                Session["report"] = rpt;
            }

        }
        catch (Exception exx)
        {
            LogManager.error("seal_seal_report_detail_kumi " + exx.Message + " " + exx.StackTrace);
        }
    }

    protected void yes(object sender, EventArgs e)
    {
        Report  rpt = (Report) Session["report"];
        Session["back"] = 1;
        TRN_ReportManager manager = new TRN_ReportManager();
        manager.admissionReport(rpt.getReportH().ReportNo, (LoginModel)Session["loginModel"]);
        Response.Redirect("seal_report_search_kumi.aspx");
    }

    protected void no(object sender, EventArgs e)
    {
        Report rpt = (Report)Session["report"];
        Session["back"] = 1;
        TRN_ReportManager manager = new TRN_ReportManager();
        manager.denialReport(rpt.getReportH().ReportNo, (LoginModel)Session["loginModel"]);
        Response.Redirect("seal_report_search_kumi.aspx");
    }
   

    protected void goBack(object sender, EventArgs e)
    {
        Session["back"] = 1;
        Response.Redirect("seal_report_search_kumi.aspx");
    }
}
